@extends('layout.master')

@section('title')
   Administrator Page - Update Product
@stop

@section('username')
   {{ Auth::user()->userName }} 
@stop

@section('header')
    @parent
@stop

@section('side-menu')
    @parent
@stop

@section('content')

	

<h3> Delete Existing Product </h3> <hr />
    
    <select size="1" id="product">
        @foreach($products as $product)
            <option value={{$product->id}}> {{ $product->productName }} </option>
        @endforeach
    </select>  <br /> <br /> 
    
    <input type="button" id="delete" value="Delete Product" class="btn btn-danger" /> 

@stop

@section('scripts')
    <script type="text/javascript">

        $(function() {

        });

        $('#delete').on('click', function() {

            var id = $('#product').val();

            $.ajax({

                url: '/api/product/delete/' +id,
                type: 'POST',
                contentType: 'application/json; charset=UTF-8',
                success: function(data) {

                    alert("Your product has been deleted successfully");
                    location.reload();
                },
                error: function() {

                    alert("Request Failed");
                } 
            });
        });
    </script>
@stop


